package com.kk.controller;

import cn.hutool.json.JSONUtil;
import com.kk.po.User;
import com.kk.service.UserInfoService;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * the class of spring_security_demo
 *
 * <p>
 * .
 *
 * @author little_lunatic
 * @date 2023-06-14
 */

@Controller
@RequestMapping("/user")
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @GetMapping("/get")
    @ResponseBody
    public User getUserInfo(@RequestParam String username) {
        return userInfoService.getUserInfoByUsername(username);
    }

    @PostMapping("/list")
    @ResponseBody
    public String login() {
        List<User> list = userInfoService.list();
        return JSONUtil.toJsonStr(list);
    }
}
